<?php
/*
|--------------------------------------------------------------------------
| Admin Routes
|--------------------------------------------------------------------------
|
| 后台公共路由部分
|
*/
Route::group(['namespace'=>'Admin','prefix'=>'admin'],function (){
    //登录、注销
    Route::get('login','LoginController@showLoginForm')->name('admin.loginForm');
    Route::post('login','LoginController@login')->name('admin.login');
    Route::get('logout','LoginController@logout')->name('admin.logout');
});


/*
|--------------------------------------------------------------------------
| Admin Routes
|--------------------------------------------------------------------------
|
| 后台需要授权的路由 admins
|
*/
Route::group(['namespace'=>'Admin','prefix'=>'admin','middleware'=>'auth'],function (){
    //后台布局
    Route::get('/','IndexController@layout')->name('admin.layout');
    //后台首页
    Route::get('/index','IndexController@index')->name('admin.index');
    Route::get('/index1','IndexController@index1')->name('admin.index1');
    Route::get('/index2','IndexController@index2')->name('admin.index2');
    //图标
    Route::get('icons','IndexController@icons')->name('admin.icons');
});

//系统管理
Route::group(['namespace'=>'Admin\SystemManage','prefix'=>'admin','middleware'=>['auth','permission:system.manage']],function (){
    //用户管理
    Route::group(['middleware'=>['permission:system.user']],function (){
        Route::get('user','UserController@index')->name('system.user');
        //获取数据
        Route::get('user/data','UserController@data')->name('system.user.data');
        //添加
        Route::get('user/create','UserController@create')->name('system.user.create')->middleware('permission:system.user.store');
        Route::post('user/store','UserController@store')->name('system.user.store')->middleware('permission:system.user.store');
        //编辑
        Route::get('user/{id}/edit','UserController@edit')->name('system.user.edit')->middleware('permission:system.user.update');
        Route::post('user/{id}/update','UserController@update')->name('system.user.update')->middleware('permission:system.user.update');
        //删除
        Route::delete('user/destroy','UserController@destroy')->name('system.user.destroy')->middleware('permission:system.user.destroy');
        //分配角色
        Route::get('user/{id}/role','UserController@role')->name('system.user.role')->middleware('permission:system.user.assignRole');
        Route::post('user/{id}/assignRole','UserController@assignRole')->name('system.user.assignRole')->middleware('permission:system.user.assignRole');
        //分配权限
        Route::get('user/{id}/permission','UserController@permission')->name('system.user.permission')->middleware('permission:system.user.assignPermission');
        Route::post('user/{id}/assignPermission','UserController@assignPermission')->name('system.user.assignPermission')->middleware('permission:system.user.assignPermission');
    });
    //角色管理
    Route::group(['middleware'=>'permission:system.role'],function (){
        Route::get('role','RoleController@index')->name('system.role');
        //获取数据
        Route::get('role/data','RoleController@data')->name('system.role.data');
        //添加
        Route::get('role/create','RoleController@create')->name('system.role.create')->middleware('permission:system.role.store');
        Route::post('role/store','RoleController@store')->name('system.role.store')->middleware('permission:system.role.store');
        //编辑
        Route::get('role/{id}/edit','RoleController@edit')->name('system.role.edit')->middleware('permission:system.role.update');
        Route::post('role/{id}/update','RoleController@update')->name('system.role.update')->middleware('permission:system.role.update');
        //删除
        Route::delete('role/destroy','RoleController@destroy')->name('system.role.destroy')->middleware('permission:system.role.destroy');
        //分配权限
        Route::get('role/{id}/permission','RoleController@permission')->name('system.role.permission')->middleware('permission:system.role.assignPermission');
        Route::post('role/{id}/assignPermission','RoleController@assignPermission')->name('system.role.assignPermission')->middleware('permission:system.role.assignPermission');
    });
    //菜单权限
    Route::group(['middleware'=>'permission:system.permission'],function (){
        Route::get('permission','PermissionController@index')->name('system.permission');
        //添加
        Route::post('permission/store','PermissionController@store')->name('system.permission.store')->middleware('permission:system.permission.store');
        //编辑
        Route::post('permission/update','PermissionController@update')->name('system.permission.update')->middleware('permission:system.permission.update');
        //删除
        Route::post('permission/destroy','PermissionController@destroy')->name('system.permission.destroy')->middleware('permission:system.permission.destroy');
    });
    //操作权限
    Route::group(['middleware'=>'permission:system.action'],function (){
        Route::get('action','ActionController@index')->name('system.action');
        //添加
        Route::post('action/store','ActionController@store')->name('system.action.store')->middleware('permission:system.action.store');
        //编辑
        Route::post('action/update','ActionController@update')->name('system.action.update')->middleware('permission:system.action.update');
        //删除
        Route::post('action/destroy','ActionController@destroy')->name('system.action.destroy')->middleware('permission:system.action.destroy');
    });

    //操作日志
    Route::group(['middleware'=>['permission:system.record']],function (){
        Route::get('logs','RecordController@index')->name('system.record');
        Route::get('logs/data','RecordController@data')->name('system.record.data');
    });
});

//平台管理
Route::group(['namespace' => 'Admin\PlatformManage', 'prefix' => 'admin', 'middleware' => ['auth', 'permission:platform.manage']], function () {

    //平台列表
    Route::group(['middleware'=>['permission:platform.platform']],function (){
        Route::get('platform','PlatformController@index')->name('platform.platform');
        //获取数据
        Route::get('platform/data','PlatformController@data')->name('platform.platform.data');
        //重新获取secret
        Route::post('platform/secret','PlatformController@secret')->name('platform.platform.secret')->middleware('permission:platform.platform.secret');
        //生成secret前验证密码
        Route::post('platform/checkPassword','PlatformController@checkPassword')->name('platform.platform.checkPassword')->middleware('permission:platform.platform.secret');
        //添加
        Route::get('platform/create','PlatformController@create')->name('platform.platform.create')->middleware('permission:platform.platform.store');
        Route::post('platform/store','PlatformController@store')->name('platform.platform.store')->middleware('permission:platform.platform.store');
        //编辑
        Route::get('platform/{id}/edit','PlatformController@edit')->name('platform.platform.edit')->middleware('permission:platform.platform.update');
        Route::post('platform/{id}/update','PlatformController@update')->name('platform.platform.update')->middleware('permission:platform.platform.update');
        //删除
        Route::delete('platform/destroy','PlatformController@destroy')->name('platform.platform.destroy')->middleware('permission:platform.platform.destroy');
    });
});